fix: route slash commands through cli.sh so uv is on PATH#11
Conversation
Add check-npm-auth target that runs npm whoami and falls back to interactive npm login if needed. Wire it into release between check-clean and bump so an unauthenticated release fails fast, before any version files are edited or commits/tags are created.
Claude Code runs the `!` bash directives in slash command .md files in a non-interactive, non-login shell that does not source ~/.zshrc, so a freshly-installed `uv` at ~/.local/bin is invisible until the user re-sources their shell rc. The four slash commands now go through a new plugin/scripts/cli.sh wrapper that bootstraps PATH the same way hook_entry.sh does, and surfaces ~/.claude-smart/install-failed when the Setup hook recorded a broken install. Also rename the adapter's two internal client calls from search_profiles to search_user_profiles to match the canonical method on ReflexioClient (the old name is deprecated upstream), and bump the reflexio submodule pointer to 0c1eced where that rename landed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an npm auth check to the Makefile release flow, introduces a Bash CLI wrapper ( ChangesCLI Wrapper & Command Integration
Profile Search API Migration
Release Process Authentication
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as User
participant CLI as Bash wrapper\n`cli.sh`
participant UV as `uv` runner
participant Python as `python -m claude_smart.cli`
Note over CLI,UV: colors: rgba(135,206,250,0.5) for CLI, rgba(144,238,144,0.5) for UV
User->>CLI: invoke `bash .../cli.sh <cmd>`
CLI->>CLI: source `_lib.sh`, run preflight hooks
CLI->>CLI: check install-failed marker
CLI-->>User: error + exit (if failed)
CLI->>CLI: verify `uv` on PATH
CLI-->>User: error + exit (if missing)
CLI->>UV: exec `uv run --project ... --quiet python -m claude_smart.cli "<cmd>"`
UV->>Python: run CLI command
Python-->>User: command output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Review rate limit: 9/10 reviews remaining, refill in 6 minutes. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Makefile`:
- Around line 39-45: Update the Makefile targets so they check for the NPM_TOKEN
env var before attempting any interactive login: in the check-npm-auth recipe
(and the release target that depends on it) first test if NPM_TOKEN is set and
accept that as authenticated, otherwise fall back to `npm whoami >/dev/null
2>&1`; if both checks fail, print a clear error like "error: not authenticated
via npm whoami and NPM_TOKEN is not set; set NPM_TOKEN for CI or run npm login
locally" and exit 1 (do not invoke interactive `npm login` in non-TTY/CI paths).
In `@plugin/src/claude_smart/reflexio_adapter.py`:
- Around line 195-201: The adapter's search_profiles method calls
client.search_user_profiles but the test mocks only implement search_profiles,
causing AttributeError swallowed by the exception handler; update the test mocks
used by tests that exercise search_profiles to expose a search_user_profiles
method (or add both search_user_profiles and search_profiles on the mock client)
so the adapter's call to client.search_user_profiles resolves correctly and the
integration is actually tested.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7a265ab6-8f3f-40dc-b938-fc185389afc7
📒 Files selected for processing (8)
Makefileplugin/commands/clear-all.mdplugin/commands/learn.mdplugin/commands/restart.mdplugin/commands/show.mdplugin/scripts/cli.shplugin/src/claude_smart/reflexio_adapter.pyreflexio
| response = client.search_user_profiles( | ||
| user_id=project_id, | ||
| query="", | ||
| top_k=top_k, | ||
| ) | ||
| except Exception as exc: # noqa: BLE001 | ||
| _LOGGER.debug("search_profiles failed: %s", exc) | ||
| _LOGGER.debug("search_user_profiles failed: %s", exc) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify every in-repo client mock/call site has been migrated to search_user_profiles.
rg -nP '\bsearch_profiles\s*\(' tests plugin/src
rg -nP '\bsearch_user_profiles\s*\(' tests plugin/srcRepository: ReflexioAI/claude-smart
Length of output: 939
🏁 Script executed:
sed -n '235,260p' plugin/src/claude_smart/reflexio_adapter.pyRepository: ReflexioAI/claude-smart
Length of output: 957
Update test mocks to provide search_user_profiles() instead of search_profiles().
The adapter's search_profiles() method now calls client.search_user_profiles() internally, but test mocks in tests/test_adapter.py still only define search_profiles(). This causes an AttributeError when tests run, which the silent exception handler at lines 197–201 and 255–259 catches and converts to an empty list. Tests pass, but the integration with the actual client API is never validated. Update the mock definitions at lines 35, 128, 182, and 198 to expose search_user_profiles() instead, or add both methods for compatibility.
Also applies to: 253–259
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugin/src/claude_smart/reflexio_adapter.py` around lines 195 - 201, The
adapter's search_profiles method calls client.search_user_profiles but the test
mocks only implement search_profiles, causing AttributeError swallowed by the
exception handler; update the test mocks used by tests that exercise
search_profiles to expose a search_user_profiles method (or add both
search_user_profiles and search_profiles on the mock client) so the adapter's
call to client.search_user_profiles resolves correctly and the integration is
actually tested.
Summary
/learn,/show,/restart,/clear-all) failed on fresh installs because Claude Code's!bash directives run in a non-interactive, non-login shell that doesn't source~/.zshrc, leaving the freshly-installeduvat~/.local/bininvisible until the user manually re-sources their rc.plugin/scripts/cli.shwrapper that bootstrapsPATHthe same wayhook_entry.shdoes, and short-circuits with the recorded reason when~/.claude-smart/install-failedis present so a broken Setup hook surfaces a useful message instead of "uv not found".client.search_profilestoclient.search_user_profilesto match the canonical method onReflexioClient(the old name is deprecated upstream).0c1eced(single-loop agentic extraction/search v2), which is where thesearch_user_profilesrename landed.18db3e4(releaseMakefilegate onnpm whoami), which had been sitting unpushed on localmain.Changes
Slash command wrapper
plugin/scripts/cli.sh(new) — bash wrapper that sources_lib.sh, callsclaude_smart_source_login_path+claude_smart_prepend_astral_bins, honors theinstall-failedmarker, thenexecsuv run --project "$PLUGIN_ROOT" --quiet python -m claude_smart.cli "$@".plugin/commands/{clear-all,learn,restart,show}.md—allowed-toolsswitched fromBash(uv run:*)toBash(bash:*); the!directive now invokesbash "$HOME/.reflexio/plugin-root/scripts/cli.sh" <subcommand> ....Adapter
plugin/src/claude_smart/reflexio_adapter.py— rename twoclient.search_profiles(...)call sites and their debug log strings tosearch_user_profiles. Adapter's own public methodAdapter.search_profilesis unchanged — only the underlying client call.Submodule
reflexio— pointer moved from9143d1b→0c1eced(agentic extraction + search v2).Release tooling (carried in from local main)
Makefile—check-npm-authtarget gatesreleaseso an unauthenticatednpm publishfails fast, before any version bump / commit / tag.Test Plan
~/.local/binis not on the inherited PATH: confirm/learn,/show,/restart,/clear-allall run successfully.~/.claude-smart/install-failedpresent, confirm a slash command prints the recorded message (not "uv not found") and exits 1.Adapter.fetch_project_profiles/Adapter.search_profilesagainst a reflexio backend at0c1eced+: confirm noAttributeErrorand profiles come back.make releaseagainst a logged-out npm: confirm it stops atcheck-npm-authbefore bumping.Notes for reviewer
18db3e4) that was sitting unpushed on localmain. Squash-merging this PR will collapse both into one commit onmain.-dirty(a deprecatedsearch_profilesalias added on top of0c1ecedfor backward compat experimentation), but the gitlink recorded here is the clean0c1ecedSHA.Summary by CodeRabbit
Chores
Documentation